/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package jogo;

import java.awt.Color;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Image;
import java.awt.Rectangle;
import java.net.URL;
import javax.swing.ImageIcon;
import javax.swing.plaf.basic.BasicTextUI;

/**
 *
 * @author Glauco
 */
public abstract class Elemento {

    private Color cor = Color.BLACK;
    private double angulo = 0;
    private Rectangle rect = new Rectangle();
    private Image img;
    private boolean circulo;
    private boolean movimento;
//    private double dx;
//    private double dy;

    public Elemento() {
    }

    public Elemento(int x, int y, int r) {
        rect = new Rectangle(x, y, 2 * r, 2 * r);
    }

    public int Raio() {
        return getRect().width / 2;
    }

    public Elemento(String nameImg) {
        URL url = Elemento.class.getResource("img/" + nameImg);
        ImageIcon aux = new ImageIcon(url);


        img = aux.getImage();
        movimento = true;

        rect = new Rectangle(100, 100, 10, 10);
    }

    public Image getImg() {
        return img;
    }

    public void setImg(Image img) {
        this.img = img;
    }

    public void desenhar(Graphics2D g) {

        //rect.translate((int)dx, (int) dy);
        g.drawImage(img, rect.x, rect.y, null);
    }

    public boolean colisao(Elemento e) {
        return this.getRect().intersects(e.getRect());
    }
    
    public double getR()
    {
        return rect.width/2;
    }
    
    public int getCX() {
        return (rect.x+(rect.width/2));
    }       

    public int getCY() {
        return (this.rect.y+(rect.height/2));
    }

    public int getX() {
        return rect.x;
    }

    public void setX(int x) {
        this.rect.x = x;
    }

    public int getY() {
        return this.rect.y;
    }

    public void setY(int y) {
        this.rect.y = y;
    }

    public Color getCor() {
        return cor;
    }

    public void setCor(Color cor) {
        this.cor = cor;
    }

    /**
     * @return the movimento
     */
    public boolean isMovimento() {
        return movimento;
    }

    /**
     * @param movimento the movimento to set
     */
    public void setMovimento(boolean movimento) {
        this.movimento = movimento;
    }

//    /**
//     * @return the dx
//     */
//    public double getDx() {
//        return dx;
//    }
//
//    /**
//     * @param dx the dx to set
//     */
//    public void setDx(double dx) {
//        this.dx = dx;
//    }
//
//    /**
//     * @return the dy
//     */
//    public double getDy() {
//        return dy;
//    }
//
//    /**
//     * @param dy the dy to set
//     */
//    public void setDy(double dy) {
//        this.dy = dy;
//    }
    /**
     * @return the Rotation
     */
    public double getAngulo() {
        return this.angulo;
    }

    /**
     * @param Rotation the Rotation to set
     */
    public void setAngulo(double Rotation) {
        this.angulo = Rotation;
    }

    /**
     * @return the rect
     */
    public Rectangle getRect() {
        return rect;
    }

    /**
     * @param rect the rect to set
     */
    public void setRect(Rectangle rect) {
        this.rect = rect;
    }

    public void MoverPara(int x, int y) {
        rect.setLocation(x, y);
    }
}
